﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MyVeryLongCake
{
    public int cut(int n)
    {
        BitArray bb = new BitArray(n);
        bb[n - 1] = true;
        int cnt = 1;
        for (int i = 2; i < n; i++)
        {
            if (n % i == 0)
            {
                for (int j = 1; i * j <= n - 1; j++)
                {
                    if (!bb[i * j])
                    {
                        bb[i * j] = true;
                        cnt += 1;
                    }
                }
            }
        }
        return cnt;
    }
}

//public class MyVeryLongCake
//{
//    public int cut(int n)
//    {
//        List<int> friends = new List<int>();
//        for (int i = 2; i <= Math.Sqrt(n); i++)
//        {
//            if (n % i == 0)
//            {
//                friends.Add(i);
//                friends.Add(n/i);
//            }
//        }

//        BitArray ba = new BitArray(n);
//        foreach (int f in friends)
//        {
//            int cut = n/f;
//            for (int i = 1; i < f; i++)
//            {
//                split[i*cut] = 1;
//            }
//        }
//        return split.Count+1;
//    }
//}

public class SlimeXSlimonadeTycoon
{
    public int sell(int[] morning, int[] customers, int stale_limit)
    {
        int n = morning.Length;
        int sell = 0;
        for (int i = 0; i < n; i++)
        {
            int subSell = 0;
            int customer = customers[i];
            for (int j = i - stale_limit + 1; j <= i; j++)
            {
                if (j < 0) j = 0;

                if (morning[j] < customer)
                {
                    subSell += morning[j];
                    morning[j] = 0;
                }
                else if (morning[j] >= customer)
                {
                    subSell += customer;
                    morning[j] -= customer;
                }
            }
            sell += subSell;
        }
        return sell;
    }
}

public class SilverbachConjecture
{
    public int[] solve(int n)
    {
        Dictionary<int, int> dic = new Dictionary<int, int>();
        for (int i = 2; i <= 2000; i++)
        {
            for (int j = 2; j <= 2000; j++)
            {
                int x = i * j;
                if (x > 2000) break;
                dic[x] = 1;
            }
        }

        for (int i = 2; i <= 2000; i++)
        {
            int other = n - i;
            if (dic.ContainsKey(i) && dic.ContainsKey(other)) return new int[] { i, other };
        }
        return new int[] { };
    }

}
